package com.alpsoft.spotcheck.adapter;

import java.util.List;
import java.util.Map;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SimpleAdapter;

public class CheckItemListViewAdapter extends SimpleAdapter {
	
	private List<? extends Map<String, ?>> mData;

	public CheckItemListViewAdapter(Context context,
			List<? extends Map<String, ?>> data, int resource, String[] from,
			int[] to) {
		super(context, data, resource, from, to);
		mData = data;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = super.getView(position, convertView, parent);
		Map<String, ?> map = mData.get(position);
		
		String is_exp = (String)map.get("is_exception");
		if("yes".equals(is_exp)){
			v.setBackgroundColor(Color.RED);
		}else{
			v.setBackgroundColor(Color.TRANSPARENT);
		}
		
		return v;
	}
}
